package com.epam.client.backingbeans;

import javax.faces.model.DataModel;
import javax.faces.model.ListDataModel;
import com.epam.DAO.RequestDAO;
import com.epam.DAO.Factories.DAOFactory;
import com.epam.entity.Client;
import com.epam.entity.Request;
import com.epam.entity.Status;
import com.epam.utils.JsfUtil;

public class ClosedRequestBean {

	private DAOFactory daoFactory;
	private RequestDAO requestDAO;
	private DataModel<Request> requests;

	private int page = 1;
	
	public ClosedRequestBean() {
		daoFactory = DAOFactory
				.getDAOFactory(DAOFactory.CURRENT_IMPLEMENTATION);
		requestDAO = daoFactory.getRequestDAO();
		requests = new ListDataModel<Request>();
	}

	public DataModel<Request> getRequests() {
		requests.setWrappedData(requestDAO.getUserRequests(
				(Client) JsfUtil.getAttribute("client"), Status.CLOSED,
				Status.CANCELLED));
		return requests;
	}

	public int getPage() {
		return page;
	}

	public void setPage(int page) {
		this.page = page;
	}

}
